All Questions
21 questions
1vote
2answers
116views
Circular list vs. doubly-linked list: which is faster?
In this post, I will compare performance of a circular list and a conventional list with head/tail -references: ...
2votes
1answer
100views
Finding better logic for addition and removal of Nodes in a Linked List
Consider the following piece of code I wrote (a templated Linked List): ...
2votes
1answer
87views
Faster, indexed, heuristic doubly-linked list data structure in Java: benchmark
I have this benchmark program for my indexed linked list. It looks like this: com.github.coderodde.util.benchmark.LinkedListBenchmarkRunner ...
2votes
1answer
228views
Faster, indexed, heuristic doubly-linked list data structure in Java: implementation
I have this doubly-linked list data structure that runs all the single-element operations in \$\Theta(\sqrt{n})\$ time (refer to this post and this repository). (See this for benchmarks.) (See this ...
3votes
1answer
351views
Java Singly-linked List: how to be efficient and clean
this is my first time on StackExchange. I am new to writing code. This is a singly-linked list I made in Java using generics with no sentinel nodes (i.e. no empty head and tail nodes). Looking for ...
2votes
2answers
209views
Brute-force ID reversal search
EDIT The random number generator in this code is a blackbox for a similar algorithm that isn't publishable for privacy concern. The algorithm works in similar way, in that it takes in a seed value ...
0votes
1answer
2kviews
A simple linked list of arrays in Java
Introduction This simple data structure combines ArrayList with LinkedList. In other words, it is a linked list of arrays: Code ...
3votes
1answer
211views
Reverse singly linked list
Description: Given a linked list reverse it and return the new head. Code: ...
0votes
3answers
2kviews
Move last node of the linked list to the front
Description: Given a linked list move the last node to the front. For example: 10 20 30 40 -> 40 10 20 30 Code: ...
7votes
1answer
9kviews
Reversing second half of linked list
I recently had an interview where I was asked to reverse the second half of a linked list. The driver program was unknown to me, I just needed to write the method to do this. The method was supposed ...
4votes
2answers
7kviews
Insert node in sorted doubly linked list
Description: Given a reference to the head of a doubly-linked list and an integer, create a new Node object having data value and insert it into a sorted linked list. Code: ...
1vote
1answer
404views
Merge sort and linked list implementation
I implemented merge sort with my own linked list for a school project. I was not allowed to use anything but the methods you see in the list. It seems to work properly, however, when running the ...
4votes
4answers
2kviews
Reversing a linked list (Java)
Triggered by an interview question (I didn't answer during the interview) I wrote a Java program to reverse a linked list. I went with a loop-based approach instead of recursion. I would like to know ...
3votes
1answer
157views
Stack from Linked List
I have written a program that takes a linked list and then converts it to a stack. I would like a code review for my program. Thanks in advance. Stack.java ...
1vote
1answer
323views
Templated linked list in Java
I recently reviewed some data structure concepts, so I implemented my own templated linked list. I am very interested about the code efficient and performance. ...